class Solution
{
public:
    int findMinDifference(vector<string> &timePoints)
    {
        int n = timePoints.size();
        if (n > 1440) // 测试点的size长达2*10^4, 但只有1440以内才需要计算
        {
            return 0;
        }
        vector<int> timeNums(n);
        for (int i = 0; i < n; ++i)
        {
            int timeNum = 60 * stoi(string(timePoints[i].begin(), timePoints[i].begin() + 2)) + stoi(string(timePoints[i].begin() + 3, timePoints[i].begin() + 5));
            timeNums[i] = timeNum;
        }
        sort(timeNums.begin(), timeNums.end());
        int minDiff = 1440;
        for (int i = 1; i < n; ++i)
        {
            minDiff = min(minDiff, timeNums[i] - timeNums[i - 1]);
        }
        minDiff = min(minDiff, 1440 + timeNums[0] - timeNums[n - 1]);
        return minDiff;
    }
};